<?php

use yii\helpers\Html;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model common\models\SetMealOrder */

$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => '订单列表', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="set-meal-order-view">

    <?= DetailView::widget([
        'model' => $model,
        'attributes' => [
            'id',
            'sn',
            'set_meal_id',
            'setMeal.title',
            'num',
            'sub_date',
            'time_frame',
            'member_id',
            'name',
            'phone',
            'address',
            [
                'attribute' => 'created_at',
                'value' => function ($m) {
                    return date('Y-m-d H:i:s', $m->created_at);
                }
            ],
            [
                'attribute' => 'updated_at',
                'value' => function ($m) {
                    return date('Y-m-d H:i:s', $m->updated_at);
                }
            ],
            'setMealItem.type_name',
            'setMealItem.price',
            'member_discount_coupon_id',
            [
                'attribute' => 'status',
                'value' => function ($m) {
                    return \common\models\SetMealOrder::$statusMap[$m->status];
                }
            ],
            [
                'attribute' => 'is_use',
                'value' => function ($m) {
                    return \common\models\SetMealOrder::$isUseMap[$m->is_use];
                }
            ],
            [
                'attribute' => 'pay_type',
                'value' => function ($m) {
                    if($m->status == \common\models\SetMealOrder::STATUS_SUCCESS) {
                        return $m->pay_type == \common\models\SetMealOrder::PAY_TYPE_WX ? "微信支付" : '支付宝支付';
                    } elseif ($m->status == \common\models\SetMealOrder::STATUS_INIT) {
                        return "未支付";
                    } else {
                        return "支付失败";
                    }

                }
            ],
            [
                'attribute' => 'pay_date',
                'value' => function ($m) {
                    return $m->pay_date ? date('Y-m-d H:i:s', $m->pay_date) : '';
                }
            ],
            [
                'attribute' => 'pay_money',
                'value' => function ($m) {
                    return \common\helpers\MoneyHelper::f2y($m->pay_money);
                }
            ],
            [
                'attribute' => 'total_money',
                'value' => function ($m) {
                    return \common\helpers\MoneyHelper::f2y($m->total_money);
                }
            ],
            [
                'attribute' => 'discount_money',
                'value' => function ($m) {
                    return \common\helpers\MoneyHelper::f2y($m->discount_money);
                }
            ],
        ],
    ]) ?>

</div>
